package com.lwj.test.statics;

import java.util.HashMap;
import java.util.Map;

public class StaticMap {

	private static Map<String, Object> dataMap = new HashMap<String, Object>();
	
	public Object getObjectById(String id){
		Object source = null;
		try {
			if (dataMap.containsKey(id)){
				source = dataMap.get(id);
				System.out.println("直接获取!");
			}else {
				source = new Object();
				dataMap.put(id, source);
				System.out.println("重新创建再获取!");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return source;
	}
}
